r'''
构造 有道背单词 格式的单词本
Input: 单词本名字（含后缀），如 word list1.txt
Output: 有道背单词格式的 单词本，与原单词本同名，生成在regularized lists文件夹下
Note: 单词本必须是txt格式，且放在original lists文件夹下
执行格式: python3 handle.py <Input your list name>
        e.g. python3 handle.py word\ list1.txt 
        注意名字中有空格需要加转义符
                        R.G.
                    2020.03.27

'''
import os,sys

PROJECT_ROOT_DIR = os.getcwd()
PROCESSING_DIR = 'original lists'
PRODUCED_DIR = 'regularized lists'

def list_regularization(list_name):
    list_path = os.path.join(PROJECT_ROOT_DIR, PROCESSING_DIR, list_name)
    with open(list_path, 'r') as f:
        word_list = f.read()
    word_join = '#' + '# #'.join(word_list.split())+ '#'
    produced_list_path = os.path.join(PROJECT_ROOT_DIR, PRODUCED_DIR, list_name)
    with open(produced_list_path, 'w') as f:
        f.write(word_join)
    print('Process completed !')

if __name__ == "__main__":
    list_regularization(sys.argv[1])